Ext.define('AM.view.EditEmployeeView', {
		extend: 'Ext.grid.Panel',
		alias : 'widget.editEmployeeView',
		store : 'EditEmpLoyeeStore',
		columnLines:true,
//		selModel : Ext.create('Ext.selection.CheckboxModel'), 
		selModel: {
	        injectCheckbox: 0,
	        mode: "SIMPLE"     //"SINGLE"/"SIMPLE"/"MULTI"
	     
   		 },
   		selType: "checkboxmodel",
    	dockedItems: [{
        xtype: 'pagingtoolbar',
        dock: 'bottom',
        store : 'EditEmpLoyeeStore',
        displayInfo: true
    }],
		columns: [	
			        {text: '序号', dataIndex: 'id',width:50,align:'center'},
			        { text: '姓名',  dataIndex: 'name',  width:80,align:'center'},
			        { text: '科室',dataIndex: 'dept', width:120,align:'center'},
			        { text: '密码',dataIndex: 'password', width:100,align:'center'},
			        { text: '人员ID', dataIndex: 'id',width:80,align:'center',hidden:true},
			        { text: '操作', dataIndex: 'id',width:80,align:'center',renderer : function(data, cell, record, rowIndex,columnIndex){
			        	    var resultStr = "<div class='controlBtn'>" +     
                            "<a href='javascript:void("+record.get('id')+");'class='alarm_detail'onclick='editpassWord("+record.get('id')+")'>修改密码</a>&nbsp;&nbsp;&nbsp;&nbsp;"   
                            "</div>";     
         					 return resultStr;  
			       		  }
         	    	}
			     ],
			     tbar: [{
					     xtype : "combobox",
					     allowBlank:false,
					     labelAlign :"right",
					     queryMode: 'local',
						 fieldLabel: '选择科室',
						 store :'TargetDepartStore',
						 displayField: 'name',
						 valueField: 'id',
						 id:'pwd_dept',
					     width:300,
					     listeners:{   
											afterrender:function(thiz){
						 	                                       if(Number(deptID)>0){
						 	                                       
						                                            thiz.setValue(Number(deptID));
						                                            thiz.setReadOnly(true);
						                                            
											}
											}
								}
					     
					  },
					  { xtype: 'button', text: '查询',handler: searchPwdemp,icon : 'Ext/restful/images/find.png'
					  }]
})
function searchPwdemp() {
		   var grid=this.ownerCt.ownerCt;
			var depart= Ext.getCmp('pwd_dept').getValue();
	       //此处为加载条件
		  grid.getStore().on('beforeload', function (store, options) {
		  	
		              var new_params = {serchdepartment:depart}
		                Ext.apply(store.proxy.extraParams, new_params);
		       });
	
		grid.getStore().reload();
					
}
function editpassWord(id) {
		var empID=id;
		 var myform1= new Ext.form.Panel({
		 			bodyPadding: 15,
			        labelWidth : 65,
					   items: [{
								    xtype : "textfield",			
						      		labelAlign :"right",
						            fieldLabel: '新密码',
						            allowBlank:false,
						            name: 'password',
						            width:280 
					   },{
					   		 xtype: 'filefield',
		                     labelAlign:'right',
		                     name: 'upload',
		                     msgTarget: 'side',
		                     buttonText:'浏览...',
		                     fieldLabel: '照片',
		                     width:280 
					   },{
					   	    xtype : "textfield",			
				      		labelAlign :"right",
				            fieldLabel: 'id',
				            allowBlank:false,
				            name: 'id',
				            value:id,
				            hidden:true,
				            width:280 
					   }]		        	
				        	       

		 })
			var win = new Ext.Window({
				title : "修改密码",
				width : 500,
				height : 250,
				frame:true,
				layout:'fit',
				items : [ myform1
							],
				buttons : [{
							text : "确定",
							handler : function() {
								win.getComponent(0).getForm().submit({
											 url : 'employees_editpassword',
											 success : function() {
												 Ext.Msg.alert('提示', '密码修改成功');
												 win.close();
												  var grid=Ext.create('AM.view.EditEmployeeView');
												  grid.getStore().reload();
												
											},
											failure : function() {
												Ext.Msg.alert('错误', '密码修改失败');
											},
											waitMsg : "请稍后，正在保存。。。。"
	
										});
							}
						}, {
							text : "重置",
							handler : function() {
								win.getComponent(0).getForm().reset();
							}
						}, {
							text : "取消",
							handler : function() {
												win.close();
											
							}
						}]
			});
		win.show();
}
 



